package com.nimitz.web.controller.pollution;

import com.nimitz.common.annotation.Log;
import com.nimitz.common.core.controller.BaseController;
import com.nimitz.common.core.domain.AjaxResult;
import com.nimitz.common.core.page.TableDataInfo;
import com.nimitz.common.enums.BusinessType;
import com.nimitz.common.utils.poi.ExcelUtil;
import com.nimitz.system.domain.SysPolluter;
import com.nimitz.system.service.SysPolluterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author nimitz
 * @date 2024-12-10
 */
@RestController
@RequestMapping("/system/polluter")
public class SysPolluterController extends BaseController
{
    @Autowired
    private SysPolluterService sysPolluterService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:polluter:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysPolluter sysPolluter)
    {
        startPage();
        List<SysPolluter> list = sysPolluterService.selectSysPolluterList(sysPolluter);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:polluter:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPolluter sysPolluter)
    {
        List<SysPolluter> list = sysPolluterService.selectSysPolluterList(sysPolluter);
        ExcelUtil<SysPolluter> util = new ExcelUtil<SysPolluter>(SysPolluter.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:polluter:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysPolluterService.selectSysPolluterById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:polluter:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPolluter sysPolluter)
    {
        return toAjax(sysPolluterService.insertSysPolluter(sysPolluter));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:polluter:edit')")
    @Log(title = "【修改功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody SysPolluter sysPolluter)
    {
        return toAjax(sysPolluterService.updateSysPolluter(sysPolluter));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:polluter:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysPolluterService.deleteSysPolluterByIds(ids));
    }
}

